class Concept:
    def __init__(self, intent=None):
        self.intent = intent if intent is not None else []
        self.children = []
        self.parents = []
        self.visited = False
        self.NewConcept = None
        self.doIntent = None
        self.MaximalConcept = None

    def get_children(self):
        return self.children

    def remove_child(self, child):
        if child in self.children:
            self.children.remove(child)

    def add_child(self, child):
        if child not in self.children:
            self.children.append(child)

    def remove_parent(self, parent):
        if parent in self.parents:
            self.parents.remove(parent)

    def add_parent(self, parent):
        if parent not in self.parents:
            self.parents.append(parent)


class ConceptLattice:
    def __init__(self):
        self.concepts = {}  # 存储概念（键：外延值元组，值：Concept 对象）

    def add_concept(self, concept):
        self.concepts[tuple(concept.intent)] = concept

    def get_concept(self, intent):
        return self.concepts.get(tuple(intent), None)

    def __str__(self):
        return '\n'.join(["Concept Intent: {}".format(concept.intent) for concept in self.concepts.values()])
